﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Text.RegularExpressions;
using System.Net;
using com.lover.common;
using System.IO;
using com.lover.astd.common.model;
using com.lover.common.http;

namespace com.lover.astd.common.partner.impl
{
    public class _8zyLogin : LoginImplBase
    {
        public _8zyLogin() : base() { }
        public override LoginResult login(ref List<Cookie> cookies, string verify_code = null, string extra = null)
        {
            LoginResult result = new LoginResult();
            logging();
            string loginurl = "http://webgame.8zy.com/as/index.php?do=login1";
            string data = String.Format("userid={0}&fmdo=login&dopost=login&gourl=http%3A%2F%2Fas.8zy.com%2Findex.html&pwd={1}&x=93&y=17", 
                _username, _password);
            HttpResult resp = TransferMgr.doPostPure(loginurl, data, ref cookies);
            if (resp == null) { result.StatusCode = LoginStatusCode.FailInLogin; return result; }

            string retstr = resp.getContent();

            if (!retstr.Contains("登录成功"))
            {
                result.StatusCode = LoginStatusCode.FailInLogin;
                return result;
            }

            string redirecturl = String.Format("http://webgame.8zy.com/as/index.php?serverid={0}", _acc.ServerId);

            processRedirect(redirecturl, result, ref cookies);
            return result;
        }
    }
}
